package cn.supermaster.management.web.rest.monitor;

import cn.supermaster.management.common.annotation.Log;
import cn.supermaster.management.common.constant.ModuleConstant;
import cn.supermaster.management.common.controller.BaseController;
import cn.supermaster.management.common.enums.BusinessType;
import cn.supermaster.management.common.page.TableDataInfo;
import cn.supermaster.management.common.response.WebResponse;
import cn.supermaster.management.system.domain.SysLogininfor;
import cn.supermaster.management.web.service.monitor.IMonitorLoginInformationService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * All rights Reserved, Designed By www.super-bytecode.com
 *
 * @ProjectName: supermaster-management
 * @Package: cn.supermaster.management.web.rest.monitor
 * @ClassName: MonitorLoginInformationRestController
 * @Description: []
 * <p> </p>
 * @Author: [Lance Ting]
 * @Date: 2021/1/10 18:13
 * @Version: V1.0
 * @Copyright: 2021 www.super-bytecode.comn Inc. All rights reserved.
 * TODO: 注意,本文件Lance Ting所作,如果转载或使用请标明具体出处!
 **/
@RestController
@RequestMapping("/monitor/logininfor")
public class MonitorLoginInformationRestController extends BaseController {

    @Autowired
    private IMonitorLoginInformationService monitorLoginInformationService;

    @RequiresPermissions("monitor:logininfor:list")
    @RequestMapping(value = "/list", method = RequestMethod.POST)
    public TableDataInfo queryLoginInformationList(SysLogininfor loginInfo) {
        return monitorLoginInformationService.queryLoginInformationList(loginInfo);
    }

    @Log(title = "登录日志", businessType = BusinessType.EXPORT)
    @RequiresPermissions("monitor:logininfor:export")
    @RequestMapping(value = "/export", method = RequestMethod.POST)
    public WebResponse doExportLoginInformation(SysLogininfor loginInfo) {
        return monitorLoginInformationService.doExportLoginInformation(loginInfo);
    }

    @RequiresPermissions("monitor:logininfor:remove")
    @Log(title = ModuleConstant.MODULE_LOGIN_LOG, businessType = BusinessType.DELETE)
    @RequestMapping(value = "/remove", method = RequestMethod.POST)
    public WebResponse removeLoginInformation(String ids) {
        return monitorLoginInformationService.doRemoveLoginInformation(ids);
    }

    @RequiresPermissions("monitor:logininfor:remove")
    @Log(title = ModuleConstant.MODULE_LOGIN_LOG, businessType = BusinessType.CLEAN)
    @RequestMapping(value = "/clean", method = RequestMethod.POST)
    public WebResponse clean() {
        return monitorLoginInformationService.doCleanLoginInformation();
    }

    @RequiresPermissions("monitor:logininfor:unlock")
    @Log(title = ModuleConstant.MODULE_ACCOUNT_UNLOCK, businessType = BusinessType.OTHER)
    @RequestMapping(value = "/unlock", method = RequestMethod.POST)
    public WebResponse doUnlockAccount(String userName) {
        return monitorLoginInformationService.doUnlockAccount(userName);
    }
}